#!/usr/bin/python
# -*- coding: utf-8 -*-
# @author: 高建平
# @description: 
#

from pydantic import Field
from typing import Generic, Optional, TypeVar, Union
from pydantic import BaseModel
from app.exceptions.status import Status

T = TypeVar('T')


class Result(BaseModel,Generic[T]):
    
    code: int = Field(..., description='code')
    message: Union[str,None] = Field(None, description='提示信息')
    data: Union[T,None]= Field(None, description='数据')

    def success(data:T):
        return Result(code=Status.HTTP_SUCCESS.code,message=None,data=data)